/**
 *查询水费年报表与搜索框的模糊查询，有模糊查询，传日期名称字段
 */

var Grid = BUI.Grid,
    Store = BUI.Data.Store,
    columns = [
        {
            title: '序号', dataIndex: 'flowDailyReportId',width:'3.4%', renderer: function (value, obj, index) {
                return index + 1;
            }
        },
        {title: '设备名称', dataIndex: 'deviceName',width:'6.9%' },
        {title: '一月', dataIndex: 'januaryWaterFee',width:'6.9%', renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');

            }
        },
        {title: '二月', dataIndex: 'februaryWaterFee',width:'6.9%',  renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '三月', dataIndex: 'marchWaterFee', width:'6.9%', renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '四月', dataIndex: 'aprilWaterFee', width:'6.9%', renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '五月', dataIndex: 'mayWaterFee',width:'6.9%',  renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '六月', dataIndex: 'juneWaterFee',width:'6.9%',  renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '七月', dataIndex: 'julyWaterFee', width:'6.9%', renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '八月', dataIndex: 'augustWaterFee',width:'6.9%',  renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '九月', dataIndex: 'septemberWaterFee',width:'6.9%',  renderer: function (value) {

                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '十月', dataIndex: 'octoberWaterFee',width:'6.9%',  renderer: function (value) {
                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '十一月', dataIndex: 'novemberWaterFee',width:'6.9%',  renderer: function (value) {
                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '十二月', dataIndex: 'decemberWaterFee',width:'6.9%',  renderer: function (value) {
                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        },
        {title: '合计', dataIndex: 'waterFeeTotalStr',width:'6.9%',  renderer: function (value) {
                return value==null||value==""?0:(value+ '').replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,');
            }
        }
    ];
//分页查询
var store = new Store({
        url: '/rest/web/flowDailyReport/selectFlowFeeYearReportPage',
        autoLoad: true, //自动加载数据
        params: { //配置初始请求的参数
            length: '15',
            start: '0',
            createTime: new Date(new Date()).Format("yyyy")
        },
        pageSize: 15,	// 配置分页数目
        root: 'data.list',
        totalProperty: 'data.totalCount'
    }),
    grid = new Grid.Grid({
        render: '#grid',
        columns: columns,
        loadMask: true, //加载数据时显示屏蔽层
        store: store,
        plugins: [Grid.Plugins.CheckSelection], // 插件形式引入多选表格
        // 底部工具栏
        bbar: {
            pagingBar: true
        }
    });

grid.render();

/**模糊搜索**/
var form = new BUI.Form.HForm({
    srcNode: '#searchForm'
}).render();

form.on('beforesubmit', function (ev) {
    //序列化成对象
    var obj = form.serializeToObject();
    obj.start = 0; //返回第一页
    store.load(obj);
    return false;
});
//点击查询
var createTime="";
$("#queryBtn").click(function(){
    $("#getDate").val($("input[name='createTime']").val());
    createTime= $("#getDate").val();
});
//点击导出按钮，导出数据
function exportData(){
    if($("#getDate").val()==""){
        window.location.href = "/rest/web/flowDailyReport/excelYearWaterFeeDownload?createTime="+new Date(new Date()).Format("yyyy");
    }else{
        window.location.href = "/rest/web/flowDailyReport/excelYearWaterFeeDownload?createTime="+createTime;
    }
}
